package com.example.active_mq;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;


@Component
public class JmsTemplateProducter {

    @Autowired
    private JmsTemplate jmsTemplate = new JmsTemplate(new ActiveMQConnectionFactory());

    public void send() {
        jmsTemplate.setExplicitQosEnabled(true);
        jmsTemplate.setDeliveryPersistent(true);
        jmsTemplate.convertAndSend(new ActiveMQQueue("test"), "测试信息");
    }

}
